package test01;

// InputFilter.java - 读取文本文件内容
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;

public class InputFilter implements Filter {

    @Override
    public Object process(Object input) {
        String filename = (String) input;
        try {
            String content = new String(Files.readAllBytes(Paths.get(filename)));
            System.out.println("输入过滤器：成功读取文件 '" + filename + "'");
            return content;
        } catch (IOException e) {
            System.err.println("输入过滤器：读取文件失败 - " + e.getMessage());
            return null;
        }
    }
}